package com.baic.ibase.models.req.devices;

import com.alibaba.fastjson2.annotation.JSONCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum CommandType {

    /**
     * 启动数据采集
     */
    START_DATA_COLLECT("start_data_collection"),
    /**
     * 停止数据采集
     */
    STOP_DATA_COLLECT("stop_data_collection"),

    /**
     * 启动数据抓包
     */
    START_PACKED_CAPTURE("start_packet_capture"),
    /**
     * 停止数据抓包
     */
    STOP_PACKED_CAPTURE("stop_packet_capture"),

    /**
     * 开始采集CAN报文
     */
    START_CAN_CAPTURE("start_can_frame_collection"),
    /**
     * 停止采集CAN报文
     */
    STOP_CAN_CAPTURE("stop_can_frame_collection"),

    /**
     * 开始采集OBD报文
     */
    START_OBD_CAPTURE("start_obd_frame_collection"),
    /**
     * 停止采集OBD报文
     */
    STOP_OBD_CAPTURE("stop_obd_frame_collection"),
    /**
     * 运行任务
     */
    START_TASK("start_task"),
    /**
     * 停止任务
     */
    STOP_TASK("stop_task"),

    /**
     * 运行用例
     */
    START_CASE("start_case"),

    /**
     * 停止用例
     */
    STOP_CASE("stop_case"),
    ;
    private final String command;

    CommandType(String command) {
        this.command = command;
    }

    public static CommandType getByCommand(String command) {
        for (CommandType value : CommandType.values()) {
            if (value.command.equals(command)) {
                return value;
            }
        }
        return null;
    }

    @JSONCreator
    public static CommandType deserialize(String command) {
        return getByCommand(command);
    }

    @JsonValue
    public String getValue() {
        return command;
    }

}
